import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, ParamMap } from '@angular/router';
import { GitConfig, GitPipelinetask } from '@api/git';
import { GitManagerService } from '@common/services/git/gitmanager';
import { Observable } from 'rxjs';

@Component({
  selector: 'kd-project-detail',
  templateUrl: './project-detail.component.html',
  styleUrls: ['./project-detail.component.scss']
})
export class ProjectDetailComponent implements OnInit {
  gitid :number
  gitConfig:Observable<GitConfig>
  gittask:Observable<GitPipelinetask[]>
  tasklist :GitPipelinetask[]=[]
  taskloguuid:string 
  constructor(
    private route: ActivatedRoute,
    private readonly git_: GitManagerService,
  ) { }
  displayedColumns: string[] = ['id', 'dir', 'commands','status','begin time','end time'];

  ngOnInit() {
    const id = this.route.snapshot.paramMap.get('gitid')!;
    this.gitid = Number(id)
    
    this.gitConfig = this.git_.getGitConfigByid(this.gitid)
    this.gittask = this.git_.GetAllPipeTaskByGitid(this.gitid)
    
    this.gittask.subscribe(
      (data) => {
        this.tasklist = data
        this.taskloguuid = data[0].id
      }
    )
  }


  ChangeLogfile(index:number){
    this.taskloguuid = this.tasklist[index].id
  }
  Hellow() {
    console.log("hellow world")
  }
}
